// Copyright (c) 2008 Matthew Johnson
// Licensed under the MIT License (see license.txt)
package actionml.tracing {
	public class Tracer {
		Trace;Appender;TextFieldAppender;TraceAppender;
		private var _tracePrototype:Trace = new Trace();
		public function Tracer(o:Object) {
			var props:Object = o.copyProperties();
			delete props["date"];
			delete props["timer"];
			_tracePrototype["setProperties"](props);
		}
		public function at(o:Object):Tracer {
			var t = new Tracer(_tracePrototype);
			o ||= {};
			t._tracePrototype["setProperties"](o);
			return t;
		}
		public function test(...message:Array) {
			this.write(Trace.TEST, message);
		}
		public function assert(...message:Array) {
			this.write(Trace.ASSERT, message);
		}
		public function trace(...message:Array) {
			this.write(Trace.TRACE, message);
		}
		public function info(...message:Array) {
			this.write(Trace.INFO, message);
		}
		public function warn(...message:Array) {
			this.write(Trace.WARNING, message);
		}
		public function error(...message:Array) {
			this.write(Trace.ERROR, message);
		}
		public function critical(...message:Array) {
			this.write(Trace.CRITICAL, message);
		}
		public function set abc(v) {
			
		}
		public function get abc() {
			
		}
		private function write(category:String, message:Array) {
			var t:Trace = new Trace();			
			t["setProperties"](_tracePrototype);
			t.category = category;
			t.message = message.join(" ");
			for each (var a:IAppender in Appender.appenders) {
				a.append(t);
			}
		}
	}
}